package com.orange.cetback.controller.admin;

import com.orange.cetback.common.vo.PageResult;
import com.orange.cetback.common.vo.Result;
import com.orange.cetback.pojo.dto.MedalLevelDTO;
import com.orange.cetback.pojo.entity.MedalLevel;
import com.orange.cetback.service.MedalLevelService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author chenenjun
 * @since 2025-04-02
 */
@Tag(name = "勋章等级接口")
@Slf4j
@RestController
@RequestMapping("/admin-api/medalLevel")
public class MedalLevelController {
    @Autowired
    private MedalLevelService medalLevelService;

    @Operation(summary = "分页查询勋章等级信息")
    @PostMapping("/page")
    public Result<PageResult<MedalLevel>> page(@RequestBody MedalLevelDTO medalLevelDTO) {
        log.info("分页查询勋章等级信息：{}",medalLevelDTO);
        PageResult<MedalLevel> pageResult = medalLevelService.pageQuery(medalLevelDTO);
        return Result.success(pageResult);
    }

    @Operation(summary = "新增勋章等级信息")
    @PostMapping("/save")
    public Result<String> add(@RequestBody MedalLevel medalLevel) {
        log.info("勋章等级实体，{}",medalLevel);
        medalLevelService.save(medalLevel);
        return Result.success("新增勋章等级信息成功");
    }

    @Operation(summary = "修改勋章等级信息")
    @PutMapping("/update")
    public Result<String> update(@RequestBody MedalLevel medalLevel) {
        medalLevelService.updateById(medalLevel);
        return Result.success("修改勋章等级信息成功");
    }


}
